import 'package:json_annotation/json_annotation.dart';

part 'brand.g.dart';

@JsonSerializable()
class BrandManufactureModel {
  @JsonKey(name: 'name', required: true)
  String name;

  @JsonKey(name: 'price', required: true)
  double price;

  @JsonKey(name: 'imgUrl', required: true)
  String imgUrl;

  /// 喜欢数量
  int? like;

  /// 好评率
  int? comment;

  /// 商品总数
  int? total;

  BrandManufactureModel({
    required this.name,
    required this.price,
    required this.imgUrl,
    this.like,
    this.comment,
    this.total,
  });

  factory BrandManufactureModel.fromJson(Map<String, dynamic> json) =>
      _$BrandManufactureModelFromJson(json);

  Map<String, dynamic> toJson() => _$BrandManufactureModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}

@JsonSerializable()
class BrandClassifyModel {
  String name;

  List<BrandModel> children;

  BrandClassifyModel({required this.name, this.children = const []});

  factory BrandClassifyModel.fromJson(Map<String, dynamic> json) =>
      _$BrandClassifyModelFromJson(json);

  Map<String, dynamic> toJson() => _$BrandClassifyModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}

@JsonSerializable()
class BrandModel {
  String name;

  String imgUrl;

  BrandModel({required this.name, required this.imgUrl});

  factory BrandModel.fromJson(Map<String, dynamic> json) => _$BrandModelFromJson(json);

  Map<String, dynamic> toJson() => _$BrandModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}
